<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="25" :xs="24">
          <el-button @click="popDistributionNewType('')" type='primary' size="mini">新分类</el-button>
          <el-button @click="popDistributionNew('')" type='primary' size="mini">选择客户</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 分类列表 </span>
          </div>
          <el-table :data="sortid">
            <el-table-column label="分类名称" prop="sort_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/crm/sale/CartogramDistribution?CMID='+emt.map['sort_id']+'&CMID5='+vueparams+'')" type='primary'>{{scope.row.sort_name}}</el-link>
              </template>
            </el-table-column>
          </el-table>
          <el-button @click="popDistributionAddRelationship('&category_id=')" type='success' size="mini"><i class='fa fa-plus'></i>增加关系</el-button>
          <el-button @click="gotoPage('/crm/sale/CartogramDistribution?CMID='+cate.map['sort_parent']+'&CMID5='+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回上级</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 分销关系 </span>
          </div>
          <el-table :data="s_list">
            <el-table-column label="客户名称" prop="client_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/crm/sale/CartogramDistribution?CMID5='+scope.row.client_id+''+vueparams+'')" type='primary'>{{scope.row.client_name}}</el-link>
              </template>
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('/crm/sale/CartogramDistribution?CMID5='+cate_client.map['client_parent']+''+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回上级</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-dialog :visible.sync="DistributionAddRelationshipVisible" append-to-body>
      <DistributionAddRelationship v-if="DistributionAddRelationshipVisible" ref="DistributionAddRelationship" :popparams="popparams"> </DistributionAddRelationship>
    </el-dialog>
    <el-dialog :visible.sync="DistributionNewTypeVisible" append-to-body>
      <DistributionNewType v-if="DistributionNewTypeVisible" ref="DistributionNewType" :popparams="popparams"> </DistributionNewType>
    </el-dialog>
    <el-dialog :visible.sync="DistributionNewVisible" append-to-body>
      <DistributionNew v-if="DistributionNewVisible" ref="DistributionNew" :popparams="popparams"> </DistributionNew>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import DistributionAddRelationship from "@/views/crm/sale/DistributionAddRelationship";
  import DistributionNewType from "@/views/crm/sale/DistributionNewType";
  import DistributionNew from "@/views/crm/sale/DistributionNew";
  export default {
    name: 'CartogramDistribution',
    components: {
      DistributionAddRelationship,
      DistributionNewType,
      DistributionNew,
    },
    props: ['popparams'],
    data() {
      return {
        DistributionAddRelationshipVisible: false,
        DistributionAddRelationshipValue: null,
        DistributionAddRelationshipDesc: null,
        DistributionNewTypeVisible: false,
        DistributionNewTypeValue: null,
        DistributionNewTypeDesc: null,
        DistributionNewVisible: false,
        DistributionNewValue: null,
        DistributionNewDesc: null,
        vueparams: this.getVUEParams(""),
        sortid: [],
        s_list: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/CartogramDistribution/cartogramDistribution?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      popDistributionAddRelationship(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.DistributionAddRelationshipVisible = !this.DistributionAddRelationshipVisible;
      },
      popDistributionNewType(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.DistributionNewTypeVisible = !this.DistributionNewTypeVisible;
      },
      popDistributionNew(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.DistributionNewVisible = !this.DistributionNewVisible;
      },
    },
  }
</script>
